package com.baizhi.service.impl;

import com.baizhi.annolation.LogAnnotation;
import com.baizhi.dao.ArticleDao;
import com.baizhi.entity.Article;
import com.baizhi.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleDao articleDao;
    @Override
    @LogAnnotation(type = "文章模块",value="查询了所有的文章信息")
    public Map selectArticle(Integer page, Integer limit) {
        Map map=new HashMap();
        List<Article> articles = articleDao.selectArticle((page - 1) * limit, limit);
        int i = articleDao.countArticle();
        map.put("data",articles);
        map.put("msg","");
        map.put("count",i);
        map.put("code",0);
        return map;
    }

    @Override
    @LogAnnotation(type = "文章模块",value="添加了文章")
    public void insertArticle(Article article) {
        articleDao.insertArticle(article);
    }

    @Override
    @LogAnnotation(type = "文章模块",value="删除文章信息")
    public void deleteArticle(Integer id) {
        articleDao.deleteArticle(id);
    }

    @Override
    @LogAnnotation(type = "文章模块",value="修改了文章信息")
    public void updateArticle(Article article) {
        articleDao.updateArticle(article);
    }
}
